package com.jingdianjichi.wx.handler;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class SubscribeMsgHandler implements WxChatMsgHandler {


    @Override
    public WxChatMsgTypeEnum getMsgType() {
        return WxChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String,String> map) {
        log.info("触发用户关注事件");
        String toUserName=map.get("FromUserName");
        String fromUserName=map.get("ToUserName");
        String subscribeEvent="感谢您的关注，我是纨绔丁少！如需随机验证码发送验证码，如需聊天则请随意聊天";
        return subscribeEvent;
    }
    private String xml(String to, String from, String text){
        long now = System.currentTimeMillis() / 1000;
        return "<xml>\n" +
                "  <ToUserName><![CDATA[" + to + "]]></ToUserName>\n" +
                "  <FromUserName><![CDATA[" + from + "]]></FromUserName>\n" +
                "  <CreateTime>" + now + "</CreateTime>\n" +
                "  <MsgType><![CDATA[text]]></MsgType>\n" +
                "  <Content><![CDATA[" + (text==null?"":text) + "]]></Content>\n" +
                "</xml>";
    }
}
